package com.chuangke.framework.service.impl;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

@Service
@Scope("prototype")
@ConditionalOnProperty(value = "spring.cache.type", havingValue = "caffeine")
public class CaffeineRetryServiceImpl implements com.chuangke.framework.service.RetryService {

	private int timeInterval = 10;// 重试计数时间间隔
	private int maxRetryTimes = 3;// 最大重试次数

	public int getTimeInterval() {
		return timeInterval;
	}

	public void setTimeInterval(int timeInterval) {
		this.timeInterval = timeInterval;
	}

	public int getMaxRetryTimes() {
		return maxRetryTimes;
	}

	public void setMaxRetryTimes(int maxRetryTimes) {
		this.maxRetryTimes = maxRetryTimes;
	}

	/**
	 * 检查是否重试超过上限
	 *
	 * @param name
	 * @param maxRetryTimes 最大重试次数
	 */
	@Override
	public void checkRetryTimes(String name, int maxRetryTimes) {

	}

	/**
	 * 登录失败计数
	 *
	 * @param name 用户名
	 * @return
	 */
	@Override
	public void retry(String name) {
	}

	@Override
	public void retrySuccessed(String name) {
	}

	@Override
	public int getRetryTimes(String name) {
		return 0;
	}

}
